/*
 * @Author       : Bing Chen chenbing@iocharger.com
 * @Date         : 2024-05-20 15:15:57
 * @LastEditors  : Bing Chen chenbing@iocharger.com
 * @LastEditTime : 2025-03-15 12:57:07
 * @FilePath     : \openchaoji-corelib\shared\include\OpenChaoJi_type.h
 * @Description  : 本头文件描述EVCC/SECC通用的类型声明
 *
 * Copyright (c) 2025 OpenChaoJi
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the icense for the specific language governing permissions and
 * limitations under the License.
 *
 */

#ifndef __OPENCHAOJI_TYPE_H__
#define __OPENCHAOJI_TYPE_H__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdbool.h>

#if 1
#include <stdint.h>
#else
/**
 * 基于标准整数尺寸的自定义整数类型
*/
typedef signed char         int8_t;		//8位有符号整数
typedef signed short int    int16_t;	//16位有符号整数
typedef signed long       	int32_t;    //32位有符号整数
// typedef signed long long   	int64_t;    //64位有符号整数

typedef unsigned char       uint8_t;  	//8位无符号整数
typedef unsigned short int  uint16_t; 	//16位无符号整数
typedef unsigned long        uint32_t; 	//32位无符号整数
// typedef unsigned long long  uint64_t; 	//64位无符号整数
#endif

/**
 * 常用无符号整数的别名
*/
typedef uint32_t  	        u32;		//32位无符号整数
typedef uint16_t	        u16;		//16位无符号整数
typedef uint8_t		        u8;		    //8位无符号整数

/**
 * 通用的传递给hal的句柄
*/
typedef void * OpenChaoJi_hal_handle;

/**
 * CAN包的id和数据基本格式
*/
union can_id_t
{
	uint32_t uint32_tWord;
	struct
	{
		uint32_t sa		:8; // Source address.
        uint32_t ps		:8; // Destination address.
		uint32_t pf		:8; // PDU Format.
		uint32_t dp		:1; // Data Page.
		uint32_t edp	:1; // Extended data page.
		uint32_t p		:3; // Priority.
		uint32_t rsvd	:3; // Reserved.
	} bit;
};

// CAN PDU defination.
struct can_pdu
{
	union can_id_t	can_id;
    uint8_t	can_dlc;
    uint8_t	data[8];
};

struct can_data {
	union can_id_t	can_id;

	uint8_t 		*data;		//!<存放实际接收的数据
	uint16_t 		len; 		//!<!<表示"data"指针所指向的数据缓冲区中的字节数。
};

struct  multiple_data {
    uint8_t  *data;  //多包数据
    uint16_t len;   //数据长度
    int src_free;   //1.表示申请者负责释放(或者申请者实际使用的静态内存，不需要使用者释放) 0.表示使用者负责释负责释放
};
#endif


